#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#define USER "USER"
#define MY_VAL "myval"
#include <string.h>
int g_val = 100;
int count = 0;
int main(int argc, char* argv[], char* env[])
{   
      //int i = 0;
      //for(i = 0; argv[i]; i++)
      //{
      //    printf("i = %d, argv[%d] = %s\n",i,i,argv[i]);
      //}
    //int i = 0;
    //for(i = 0; env[i]; i++)
    //{
    //    printf("i = %d, env[%d] = %s\n",i,i,env[i]);
    //}
    //extern char** environ;
    //int i = 0;
    //for(i = 0; environ[i]; i++)
    //{
    //    printf("i = %d, environ[%d] = %s\n",i,i,environ[i]);
    //}

    //char* who = getenv(MY_VAL);
    //if(who == NULL)
    //{
    //    printf("getenv(%s) fail\n",MY_VAL);
    //}
    //else
    //{
    //  printf("getenv(%s) sucess\n", MY_VAL);
    //}
    //char* who = getenv(USER);
    //if (strcmp(who,"root") == 0)
    //{
    //    printf("User name is %s\n", who);
    //}
    //else{
    //    printf("permissions deny!\n");
    //}
    
    
    //pid_t pid = fork();
    //if(pid == 0)
    //{ 
    //  while(1)
    //  {
    //    printf("This is child process, pid = %d, ppid = %d, g_val = %d, &g_val = %p\n",getpid(),getppid(),g_val,&g_val);
    //    sleep(1);
    //    count++;
    //    if(count == 10)
    //    {
    //        g_val = 300;
    //        printf("g_val has modify.\n");
    //    }
    //  }
    //}
    //
    //else if(pid > 0)
    //{ 
    //  while(1)
    //  {
    //    printf("This is parent process, pid = %d, ppid = %d, g_val = %d, &g_val = %p\n",getpid(),getppid(),g_val,&g_val);
    //    sleep(1);
    //  }
    //}

    //else
    //{
    //  printf("error.\n");
    //}
    return 0;
}
